
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2839
 * @Author : WangRuoyu 
 * @Date : 2023/9/5 16:45
 */

#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    bool canBeEqual(string s1, string s2) {
        int nums1[26] = {0};
        int nums2[26] = {0};
        for (int i = 0; i < s1.size(); i += 2) {
            nums1[s1[i] - 'a']++;
            nums2[s2[i] - 'a']++;
        }
        for (int i = 0; i < 26; ++i) {
            if (nums1[i] != nums2[i]) return false;
            else {
                nums1[i] = 0;
                nums2[i] = 0;
            }
        }
        for (int i = 1; i < s1.size(); i += 2) {
            nums1[s1[i] - 'a']++;
            nums2[s2[i] - 'a']++;
        }
        for (int i = 0; i < 26; ++i) {
            if (nums1[i] != nums2[i]) return false;
        }
        return true;
    }
};

int main() {
    Solution sl;
    string s1 = "abcd";
    string s2 = "cdab";
    cout << sl.canBeEqual(s1, s2);
    return 0;
}